<template>
  <view>
    <uv-button @click="selectFile">选择视频</uv-button>
  </view>
</template>

<script>

export default {
  data() {
    return {}
  },
  methods: {
    selectFile() {
      uni.chooseVideo({
        success: (res) => {
          console.log(res)
          // 上传视频
          uni.uploadFile({
            url: this.$hd.baseUrl + '/common/upload',
            filePath: res.tempFilePath,
            name: 'file',
            header: {
              Authorization: "Bearer " + uni.getStorageSync('token'),
            },
            success: (result) => {
              console.log(result)
            }
          })
          // 上传视频封面
          if (res.thumbTempFilePath)
            uni.uploadFile({
              url: this.$hd.baseUrl + '/common/upload',
              filePath: res.thumbTempFilePath,
              name: 'file',
              header: {
                Authorization: "Bearer " + uni.getStorageSync('token'),
              },
              success: (result) => {
                console.log(result)
              }
            })
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
